<template>
  <div>
    <h3>歌曲详情</h3>
    {{ singxq }}
    <p>当前歌曲的id{{ obj }}</p>

    <p>当前歌曲为  ---{{ singxq.name }}</p>
    <p>当前歌曲的作者为---{{ singxq.singn }}</p>
    <p>当前歌曲的作者为---{{ singxq.shichang }}</p>
    <!-- <el-button @click="tiaozhuan">跳转到登录界面</el-button> -->
    <el-button @click="like">添加到收藏歌单中</el-button>
  </div>
</template>

<script>
import axios from 'axios'
export default {
    data(){
        return{
            obj:this.$route.params.id,
            singxq:{}
        }
    },
    mounted(){
        this.getD()
    },
    methods:{
        getD(){
            axios.get('http://127.0.0.1:8000/user/xqsing/'+this.obj+'/')
            .then(resp=>{
                console.log(resp);
                this.singxq=resp.data.data
            })
            .catch(err=>{
                console.log(err);
            })
            
        },
        like(){
            axios.post('http://127.0.0.1:8000/user/collects/',
            {
                user:this.$store.state.getUser,
                obj:this.obj,
                token:localStorage.getItem('token')
            })
            
            .then(resp=>{
                console.log(resp);
                if(resp.data.code == 200){
                    alert('收藏歌曲成功')
                }else{
                    alert(resp.data.msg)
                }
            })
            .catch(err=>{
                console.log(err);
            })
        }
    }
}
</script>

<style>

</style>